<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
    <head>
        <title>Title</title>
        <script src="js/jquery-3.3.1.js"></script>
    </head>
    <body>

        <h6>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[发送]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</h6>
        <h6>|~~~~~~~~~[get]~~~~~~~~~~~~|</h6>
        <form action="${pageContext.request.contextPath}/communication/reqParameter" method="get">
            <table>
                <tr>
                    <td>用户名:</td>
                    <td><input type="text" name="username"></td>
                </tr>
                <tr>
                    <td>密码:</td>
                    <td><input type="password" name="password"></td>
                </tr>
                <tr>
                    <td colspan="2"><input type="submit" value="登录"></td>
                </tr>
            </table>
        </form>


        <h6>|~~~~~~~~~[post]~~~~~~~~~~~~|</h6>
        <form action="${pageContext.request.contextPath}/communication/reqParameter" method="post">
            <table>
                <tr>
                    <td>用户名:</td>
                    <td><input type="text" name="username"></td>
                </tr>
                <tr>
                    <td>密码:</td>
                    <td><input type="password" name="password"></td>
                </tr>
                <tr>
                    <td colspan="2"><input type="submit" value="登录"></td>
                </tr>
            </table>
        </form>






        <h6>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[接收]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</h6>
        <h6>|~~~~~~~~~[json]~~~~~~~~~~~~|</h6>
        <script>
            $(function () {
                $("#btn1").click(function () {
                    $.get("communication/respJSON",{},function (data) {
                        var json = '';
                        json += data.flag+",";
                        json += data.data+",";
                        json += data.errorMsg;
                        $("#s1").html(json);
                    })
                })
            });
        </script><br>
        <span id="s1"></span><br>
        <input  type="button" id="btn1" value="获取json数据">


        <h6>|~~~~~~~~~[页面]~~~~~~~~~~~~|</h6><br>
        <script>
            $(function () {
                $("#btn2").click(function () {
                    $.get("communication/respPage",{},function (data) {
                        alert(data);
                        $("#s2").html(data);
                    })
                })
            });
        </script><br>
        <span id="s2"></span><br>
        <button  id="btn2">获取页面</button><br>




        <h6>|~~~~~~~~~[图片]~~~~~~~~~~~~|</h6><br>
        <script>
            $(function () {
                $("#btn3").click(function () {
                    $("#img1").attr("src","communication/respImage?"+new Date().getTime());
                })
            });
        </script><br>
        <img id="img1" src="communication/respImage">
        <button  id="btn3">获取图片</button>



        <br>
    </body>
</html>

























